// 是否打开登录弹框
export const dialogLogin = (state) => state.dialogLogin;

// 登录状态
export const loginStatu = (state) => {
  return (
    state.loginStatu || JSON.parse(window.localStorage.getItem("loginStatu"))
  );
};

// 用户信息
export const userInfo = (state) => {
  if (
    state.loginStatu ||
    JSON.parse(window.localStorage.getItem("loginStatu"))
  ) {
    return (
      state.userInfo || JSON.parse(window.localStorage.getItem("userInfo"))
    );
  } else {
    return null;
  }
};

// 验证码次数
export const codeCount = (state) => {
  return (
    state.codeCount || JSON.parse(window.sessionStorage.getItem("codeCount"))
  );
};

// 导航栏信息
export const navData = (state) => {
  return state.navData || JSON.parse(window.sessionStorage.getItem("navData"));
};
// 是否打开播放列表(抽屉)
export const isDrawer = (state) => state.isDrawer;

// 高级搜索字段
export const searchForm = (state) => state.searchForm;

// 当前播放单曲信息
// export const playInfo = (state) => state.playInfo;

//当前播放单曲父级ID
export const playParentId = (state) => state.playParentId;

//当前播放单曲夹子ID
export const playClipId = (state) => state.playClipId;

// 播放状态
export const playing = (state) => state.playing;

// 播放列表
export const playList = (state) => state.playList;

// 保存的播放列表
export const playLists = (state) => {
  // if (
  //   state.loginStatu ||
  //   JSON.parse(window.localStorage.getItem("loginStatu"))
  // ) {
  return (
    state.playLists || JSON.parse(window.localStorage.getItem("__playList__"))
  );
  // } else {
  //   return [];
  // }
};

// 顺序列表
export const sequenceList = (state) => state.sequenceList;

// 当前播放模式(循环，单曲，随机)
export const mode = (state) => state.mode;

// 当前播放索引
export const currentIndex = (state) => state.currentIndex;

// 当前播放歌曲
export const currentSong = (state) => {
  // if (
  //   state.loginStatu ||
  //   JSON.parse(window.localStorage.getItem("loginStatu"))
  // ) {
  return state.playList[state.currentIndex] || {};
  // } else {
  //   return {};
  // }
};

// 搜索历史
export const searchHistory = (state) => {
  return state.searchHistory;
};

// 收藏列表
export const historyList = (state) => {
  // return state.historyList.map(song => {
  //   return new song(song)
  // })
  return state.historyList;
};

// 判断是否 移动端
export const isMobile = (state) => state.isMobile;

// 判断是 Android or Ios
export const isAndOrIos = (state) => state.isAndOrIos;

// 判断是否 IE
export const isIE = (state) => state.isIE;
